'''
异常处理，就是为了把一些不太重要的BUG隐藏起来，有时候利用异常报错解决问题
'''
try:
    print(1234)
    print(x)
    print(123+'13')
except NameError as e:
    print('这里有错误，错误为:',e)

else:
    print('触发了else')#try语句块里全部正常执行完毕后运行
finally:
    print('触发finally')

a=[1,2,3,[4,5,6,[7,8,9],(10,11,12)],13,14]
s=set()
def find_element(n):
    for i in n:
        try:
            for j in i:
                find_element(i)
        except Exception:
            s.add(i)
find_element(a)
print(s)

a=[1,2,3,[4,5,6,[7,8,9],(10,11,12)],13,14]
def find_element(n):
    for i in n:
        try:
            for j in i:
                find_element(i)
                break
        except Exception:
            # s.add(i)
            print(i)
find_element(a)

#自定义异常，必须继承EXCEPTION


class Myerror(Exception):
    pass
print(1)
raise Myerror
print(2)


